#pragma once

#include <physics/Joint.h>
#include <physics/Registrator.h>
#include <physics/Node.h>

struct b2DistanceJointDef;

namespace physics
{

class DistanceJoint: public Joint
{
	PHYSICS_JOINT_REGISTER(DistanceJoint)

protected:
	virtual bool on_node(xml::Provider *prov, const std::string &name);

public:
	DistanceJoint(World *world);
	DistanceJoint(World *world, Node *nodeA, Node *nodeB, const Vector2 & anchorA, const Vector2 & anchorB, float length, float frequencyHz, bool collideConnected);
	DistanceJoint(World *world, Node *nodeA, Node *nodeB, const Vector2 & anchorA, const Vector2 & anchorB, float length);
	DistanceJoint(World *world, Node *nodeA, Node *nodeB, const Vector2 & anchorA, const Vector2 & anchorB, float minLength, float maxLength);
	DistanceJoint(World *world, Node *nodeA, Node *nodeB, const Vector2 & anchorA, const Vector2 & anchorB);
	virtual ~DistanceJoint();

	b2DistanceJointDef* GetJointDef() const { return (b2DistanceJointDef*) jointDef.get(); }
};

}